package example.controller;

import example.common.Result;
import example.service.ISelectionResponseService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/api/rep")
public class SelectionResponseController {

    @Resource
    private ISelectionResponseService selectionResponseService;

    @GetMapping("/list/{id}")
    public Result getSelectionResponse(@PathVariable("id") Long selectionId) {
        return selectionResponseService.getSelectionResponse(selectionId);
    }

    @GetMapping("/name/{id}")
    public Result getSelectionResponseFileName(@PathVariable("id") Long id) {
        return selectionResponseService.getSelectionResponseFileName(id);
    }

    @GetMapping("/file/{id}")
    public void getSelectionResponseFile(@PathVariable("id") Long id, HttpServletResponse response) {
        selectionResponseService.getSelectionResponseFile(id, response);
    }

    @PostMapping("/response")
    public Result uploadZip(@RequestParam MultipartFile file, Long selectionId, String departmentName) {
        return selectionResponseService.uploadZip(file, selectionId, departmentName);
    }
}
